﻿/// <reference path="RequestHandler.js" />
/// <reference path="../HttpRequest.js" />
/// <reference path="../../enhancements/QuickReply.js" />
/// <reference path="../../utilities/Markup.js" />
/// <reference path="../../utilities/Xpcom.js" />
///--------------------------------------------------------------------
/// <file name="DeleteMessageHandler.js">
///   Adds markup buttons to the delete message page, only when a
///   moderator is deleting another person's message.
/// </file>
///--------------------------------------------------------------------

NAMFox.ns(function() { with (NAMFox) {

this.DeleteMessageHandler = function() {
};

DeleteMessageHandler.prototype = new RequestHandler();
DeleteMessageHandler.prototype.name = "DeleteMessageHandler";

DeleteMessageHandler.prototype.handleRequestCore = function(request, _$) {
    /// <summary>Handles a request.</summary>
    /// <param name="request" type="HttpRequest">
    ///   The HTTP request which encapsulates the
    ///   document and route data for this request.
    /// </param>
    
    var textArea = _$("textarea[name=pm_body]");
    
    // There's only a text area here if you delete another person's message.
    if (textArea.length === 1) {
        request.htmlDocument.__namfox__.textArea = textArea;
        textArea.after('<div id="namfox-delete-message-markup-bar"></div>');
        
        _$("#namfox-delete-message-markup-bar").
            css("width", textArea.attr("clientWidth") + "px").
            append(
                Markup.create(textArea, MarkupLocation.DeleteMessage, Markup.customMessages)
            );
            
        var privateMessages = $.getConfig().privateMessages;
        _$("input[name=read_rcpt]").attr("checked", privateMessages.readReceipt);
    }
};

}});